<template>
    <div class="city-container">
        <Header></Header>
        <Search :cities="cities"></Search>
        <List 
        :cities="cities" 
        :hotCities="hotCities"
        :letter="letter"
        ></List>
        <Cityalphabet 
        :cities="cities"
        @change="letterChange"
        ></Cityalphabet>
    </div>
</template>

<script>
import cityHeader from './components/Header.vue'
import search from './components/search.vue'
import list from './components/list.vue'
import cityalphabet from './components/Alphabet.vue'

import axios from 'axios'


export default {
    name :'city' ,
    data(){
        return {
            cities:{},
            hotCities:[],
            letter:''
        }
    },
    components : {
        Header : cityHeader,
        Search : search,
        List : list,
        Cityalphabet : cityalphabet
    },
    methods:{
        getCityIfo(){
            axios.get('../../../static/mock/city.json')
                .then(this.getCityInfoSucc)
            },
        getCityInfoSucc(res){
            console.log(res)
            res = res.data
            if (res.ret && res.data){
                const data = res.data
                this.cities =data.cities
                this.hotCities = data.hotCities
            }
        },
        letterChange(e){
            this.letter = e
        }
    },
    mounted () {
        this.getCityIfo()
    }
}
</script>

<style lang="stylus" scoped>
.city-container{
    background-color white
}
</style>
